NOTE
1.32 InnoDB undo log
1. What Is undo log - A log of the MySQL InnoDB storage engine - Mainly records logical changes to data - An INSERT statement corresponds to a DELETE undo log - An UPDATE statement corresponds to an opposite UPDATE undo log - A DELETE statement corresponds to an INSERT undo log - Before actually inserting, deleting, or modifying a record, the corresponding undo log needs to be recorded first
This is a historical learning note and may contain outdated or incomplete understanding.
1. What Is undo log
- A log of the MySQL InnoDB storage engine.
- Mainly records logical changes to data.
- An
INSERTstatement corresponds to aDELETEundo log. - An
UPDATEstatement corresponds to an oppositeUPDATEundo log. - A
DELETEstatement corresponds to anINSERTundo log.
- An
- Before actually inserting, deleting, or modifying a record, the corresponding undo log needs to be recorded first.
2. Why undo log Is Needed
2.1. Implement Atomicity
- If a crash occurs halfway through a transaction, after restart the incomplete modifications need to be undone. This requires undo log.
2.2. Implement MVCC
3. undo log Implementation
3.1. Deletion Timing
- When no transaction needs these rollback logs anymore, the rollback logs are deleted. Therefore, try not to use long transactions.
Discussion
Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub